<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>移动鼠标：mouseover/out，mouseenter/leave</title>
		<style>
			div {
				width: 200px;
				height: 200px;
			}

			div:nth-child(1) {
				background-color: pink;
			}

			div:nth-child(2) {
				background-color: skyblue;
			}
		</style>
	</head>
	<body>
		<div class="box1">DIV1</div>
		<div class="box2">DIV2</div>

		<script>
			const div2 = document.querySelector('.box2')

			// mouseover 鼠标移入时触发
			div2.addEventListener('mouseover', function (e) {
				console.log('鼠标来自于哪个元素', e.relatedTarget)
				console.log('鼠标移入的当前元素', e.target)
			})

			// mouseout 鼠标移出时触发
			div2.addEventListener('mouseout', function (e) {
				console.log('鼠标来自于哪个元素', e.target)
				console.log('鼠标移入的当前元素', e.relatedTarget)
			})
		</script>
	</body>
</html>
